package com.yipei.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.enums.BusinessType;
import com.yipei.business.domain.MlInvestmentType;
import com.yipei.business.service.IMlInvestmentTypeService;
import com.yipei.common.utils.poi.ExcelUtil;
import com.yipei.common.core.page.TableDataInfo;

/**
 * 基金分类Controller
 * 
 * @author yipei
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/business/investtype")
public class MlInvestmentTypeController extends BaseController
{
    @Autowired
    private IMlInvestmentTypeService mlInvestmentTypeService;

    /**
     * 查询基金分类列表
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(MlInvestmentType mlInvestmentType)
    {
        startPage();
        List<MlInvestmentType> list = mlInvestmentTypeService.selectMlInvestmentTypeList(mlInvestmentType);
        return getDataTable(list);
    }

    /**
     * 导出基金分类列表
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:export')")
    @Log(title = "基金分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlInvestmentType mlInvestmentType)
    {
        List<MlInvestmentType> list = mlInvestmentTypeService.selectMlInvestmentTypeList(mlInvestmentType);
        ExcelUtil<MlInvestmentType> util = new ExcelUtil<MlInvestmentType>(MlInvestmentType.class);
        util.exportExcel(response, list, "基金分类数据");
    }

    /**
     * 获取基金分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mlInvestmentTypeService.selectMlInvestmentTypeById(id));
    }

    /**
     * 新增基金分类
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:add')")
    @Log(title = "基金分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlInvestmentType mlInvestmentType)
    {
        return toAjax(mlInvestmentTypeService.insertMlInvestmentType(mlInvestmentType));
    }

    /**
     * 修改基金分类
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:edit')")
    @Log(title = "基金分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlInvestmentType mlInvestmentType)
    {
        return toAjax(mlInvestmentTypeService.updateMlInvestmentType(mlInvestmentType));
    }

    /**
     * 删除基金分类
     */
    @PreAuthorize("@ss.hasPermi('business:investtype:remove')")
    @Log(title = "基金分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mlInvestmentTypeService.deleteMlInvestmentTypeByIds(ids));
    }
}
